@extends('layouts.app')

@section('content')
<!-- Main content -->
<section class="content">

  <div class="row">
    <div class="col-md-3">
      <!-- About Me Box -->
      <div class="box box-primary">
        <div class="box-header with-border">
          <h3 class="box-title">{{ $admin->name }}</h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <strong>邮箱</strong>

          <p class="text-muted">
            {{ $admin->email }}
          </p>

          <hr>

          <strong>加入时间</strong>

          <p class="text-muted">{{ $admin->created_at }}</p>

          <hr>

          <strong>角色</strong>

          <p>
            @if(count($admin->roles))
              @foreach($admin->roles as $role)
                <span class="label label-success">{{ $role->display_name }}</span>
              @endforeach
            @else
              无角色
            @endif
          </p>
        </div>
        <!-- /.box-body -->
      </div>
      <!-- /.box -->
    </div>

    <div class="col-md-9">
      @include('layouts.utils.success')
      <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
          <li class="active"><a href="#profile" data-toggle="tab">编辑基本信息</a></li>
          <li><a href="#account" data-toggle="tab">账户安全</a></li>
        </ul>
        <div class="tab-content">
          <div class="active tab-pane" id="profile">
            <form class="form-horizontal" action="{{ url('/api_admin/profile/'.$admin->id) }}" method="post">
              {!! csrf_field() !!}
              <div class="form-group {{ $errors->has('name') ? ' has-error' : '' }}">
                <label for="name" class="col-sm-2 control-label">用户名</label>

                <div class="col-sm-10">
                  <input type="text" class="form-control" name="name" value="{{ $admin->name }}" id="name" placeholder="用户名">
                  @if ($errors->has('name'))
                  <span class="help-block">
                    <strong>{{ $errors->first('name') }}</strong>
                  </span>
                  @endif
                </div>
              </div>
              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                  <button type="submit" class="btn btn-primary">修改</button>
                </div>
              </div>
            </form>
          </div>
          <!-- /.tab-pane -->

          <div class="tab-pane" id="account">
            <form class="form-horizontal" method="POST" action="{{ url('/api_admin/profile/password/reset') }}">
              {!! csrf_field() !!}
              
              <input type="hidden" name="email" value="{{ $admin->email }}">

              <div class="form-group {{ $errors->has('password_current') ? ' has-error' : '' }}">
                <label for="password_current" class="col-sm-2 control-label">密码</label>

                <div class="col-sm-10">
                  <input type="password" class="form-control" name="password_current" id="password_current" placeholder="密码">
                  @if ($errors->has('password_current'))
                  <span class="help-block">
                    <strong>{{ $errors->first('password_current') }}</strong>
                  </span>
                  @endif
                </div>
              </div>

              <div class="form-group {{ $errors->has('password') ? ' has-error' : '' }}">
                <label for="password" class="col-sm-2 control-label">新密码</label>

                <div class="col-sm-10">
                  <input type="password" class="form-control" name="password" id="password" placeholder="新密码">
                  @if ($errors->has('password'))
                  <span class="help-block">
                    <strong>{{ $errors->first('password') }}</strong>
                  </span>
                  @endif
                </div>
              </div>

              <div class="form-group {{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
                <label for="password_confirmation" class="col-sm-2 control-label">确认密码</label>

                <div class="col-sm-10">
                  <input type="password" class="form-control" name="password_confirmation" id="password_confirmation" placeholder="确认密码">
                  @if ($errors->has('password_confirmation'))
                  <span class="help-block">
                    <strong>{{ $errors->first('password_confirmation') }}</strong>
                  </span>
                  @endif
                </div>
              </div>

              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                  <button type="submit" class="btn btn-danger">修改密码</button>
                </div>
              </div>
            </form>
          </div>
          <!-- /.tab-pane -->
        </div>
        <!-- /.tab-content -->
      </div>
      <!-- /.nav-tabs-custom -->
    </div>
    <!-- /.col -->
  </div>
  <!-- /.row -->

</section>
<!-- /.content -->
@endsection